package com.ttai.presenter.activity;

import android.content.Intent;
import android.widget.Toast;

import com.google.gson.JsonObject;
import com.ttai.model.net.ResponseInfo;
import com.ttai.presenter.base.BasePresenter;
import com.ttai.ui.activity.ResetKey;
import com.ttai.ui.activity.UaP_Protect;

import retrofit2.Call;

public class ResetKeyPresenter extends BasePresenter{
    ResetKey resetKey;

    public ResetKeyPresenter(ResetKey resetKey) {
        this.resetKey = resetKey;
    }

    @Override
    protected void showError(String message) {
        Toast.makeText(resetKey,message,Toast.LENGTH_SHORT).show();
    }

    @Override
    protected void parseJson(JsonObject json) {
        Toast.makeText(resetKey,"密钥修改成功",Toast.LENGTH_SHORT).show();
        resetKey.finish();
        Intent intent = new Intent(resetKey, UaP_Protect.class);
        resetKey.startActivity(intent);
    }

    public void resetEncrypt(String token,String oldKey,String newKey,String accountList,String keyTip){
        Call<ResponseInfo> encryptInfo = responseInfoApi.newEncrypt(token, oldKey, newKey, accountList,keyTip);
        encryptInfo.enqueue(new CallBackAdapter());
    }
}
